<html>
	<head>
		<title>District Delete form</title>
		<link rel="stylesheet" href="style.css">
	</head>
	<body>
		<table>
			<tr>
				<td colspan="2" id="pageheader">
					health information system
				</td>
			</tr>
			<tr>
				<td id="mainnav">
					<div class="menuitem">location</div>
					<div class="menuitem">opd cases</div>
					<div class="menuitem">health promotion</div>
					<div class="menuitem">nutrition</div>
					<div class="menuitem">child welfare</div>
					<div class="menuitem">family planning</div>
				</td>
				<td id="content">
					<div id="divPageMenu">
						<span class="menuitem" >sub districts</span>
						<span class="menuitem" >communities</span>
						<span class="menuitem" >view map</span>
						<input type="text" id="txtSearch">
						<span class="menuitem">search</span>		
					</div>
					<div id="divStatus" class="status">
						status message
					</div>
					<div id="divContent">
						<form action="district_delete.php" method="POST">
							<table class="tableForm">
								<tr>
									<td class="label">District Name: </td>
									<td class="field">
										<?php DistrictDropDrown(); ?>
									</td>
								</tr>
								<tr>
									<td class="label"></td>
									<td class="field"><input type="submit" name="submit" value="delete"/></td>
								</tr>	
							</table>
						</form>
					</div>
				</td>
			</tr>
		</table>
		
		
		<?php
			
			include_once("district_functions.php");
			
			$new_dist = new district();
			
			if (isset($_REQUEST['district_name'])){
				$new_dist->delete_row($_REQUEST['district_name']);
				echo "deleted!";
			}
		
		function DistrictDropDrown(){
		include_once("district_functions.php");
		
		$obj = new district();
		
		$obj->list_all();
		
		echo "<select name='district_name'>";
			echo "<option value='0'>All</option>";
			do{
				$item = $obj->fetch();
				echo "<option value=$item[district_name]>$item[district_name]</option>";
			} while($item);
			echo "</select>";
		}
		?>
		
	</body>
</html>

